command_obfuscator.py

Base class for Command Obfuscators used by the framework

class bashfuscator.core.mutators.command_obfuscator.CommandObfuscator(name, description, sizeRating, timeRating, notes=None, author=None, credits=None, evalWrap=True, unreadableOutput=False, reversible=False)[source]

Bases: bashfuscator.core.mutators.mutator.Mutator

Base class for all Command Obfuscators. If an obfuscator takes the original input, mutates it, and requires a deobfuscation stub to execute, then it is a Command Obfuscator.

Parameters:
  • name (str) – name of the CommandObfuscator
  • description (str) – short description of what the CommandObfuscator does
  • sizeRating (int) – rating from 1 to 5 of how much the CommandObfuscator increases the size of the overall payload
  • timeRating (int) – rating from 1 to 5 of how much the CommandObfuscator increases the execution time of the overall payload
  • reversible (bool) – True if the obfuscator cancels itself out when run twice in a row on a command/script, False otherwise
  • fileWrite (bool) – True if the Command Obfuscator requires creating/writing to files, False otherwise
  • notes (str) – see bashfuscator.common.objects.Mutator
  • author (str) – see bashfuscator.common.objects.Mutator
  • credits (str) – see bashfuscator.common.objects.Mutator
class bashfuscator.core.mutators.command_obfuscator.Stub(name, sizeRating, timeRating, binariesUsed, fileWrite, escapeQuotes, stub)[source]

Bases: object

This class is in charge of generating a valid deobfuscation stub, taking care of properly escaping quotes in the user’s input, generating random variable names, and so on.

Parameters:
  • name – name of the Stub
  • binariesUsed (list of strs) – all the binaries used in the stub
  • sizeRating (int) – rating from 1 to 5 of how much the Stub increases the size of the overall payload
  • timeRating (int) – rating from 1 to 5 of how much the Stub increases the execution time of the overall payload
  • escapeQuotes (int) – True if the stub requires any quotes in the original command to be escaped, False otherwise
  • stub (str) – string containing the actual stub
genStub(userCmd)[source]

Generate a valid deobfuscation stub and wrap an obfuscated command in it.

Parameters:userCmd (str) – command that need to be wrapped in a deobfuscation stub